/*
package com.snow.dayou.util;


import com.snow.dayou.config.MinioConfig;
import io.minio.MinioClient;
import io.minio.ObjectStat;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Optional;

@Component
@Slf4j
@Data
@Configuration
@EnableConfigurationProperties({MinioConfig.class})
public class MinioUtils {

    private final static String BUCKETNAME = "test";

    private MinioConfig minioConfig;
    private MinioClient instance;

    public MinioUtils(MinioConfig minioConfig) {
        this.minioConfig = minioConfig;
    }

    @PostConstruct
    public void init() {
        try {
            instance = new MinioClient(minioConfig.getEndpoint(), minioConfig.getAccessKey(), minioConfig.getSecretKey());
            log.info(">>>>>>>>>>>>>>>>>>>>Minio连接成功,url:{}<<<<<<<<<<<<<<<<<<<", minioConfig.getEndpoint());
        } catch (InvalidEndpointException e) {
            e.printStackTrace();
        } catch (InvalidPortException e) {
            e.printStackTrace();
        }
    }

    */
/**
     * 上传文件
     *//*

    public void uploadFile() {
        try {
            String s = RandomStringUtils.random(10, true, true);
            s = s + ".jpg";
            instance.putObject(BUCKETNAME, s, "C:\\Users\\Administrator\\Desktop\\20200407143347948.png", null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    */
/**
     * 是否存在对象
     *//*

    public Boolean isExistObject(String object) {
        try {
            ObjectStat objectStat = instance.statObject(BUCKETNAME, object);
            return Optional.ofNullable(objectStat).isPresent();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    */
/**
     * 获取外链
     *//*

    public String presignedGetObject(String object) {
        String presignedGetObject = null;
        try {
            presignedGetObject = instance.presignedGetObject(BUCKETNAME, object);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Optional.ofNullable(presignedGetObject).<RuntimeException>orElseThrow(() -> {
            throw new RuntimeException();
        });
        return presignedGetObject;
    }

    */
/**
     * 获取外链,有效期
     *//*

    public String presignedGetObject(String object, int expire) {
        String presignedGetObject = null;
        try {
            presignedGetObject = instance.presignedGetObject(BUCKETNAME, object, expire);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Optional.ofNullable(presignedGetObject).<RuntimeException>orElseThrow(() -> {
            throw new RuntimeException();
        });
        return presignedGetObject;
    }
}
*/
